﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GameNode_with_my_node
{
   
        class Drawer
        {
            public Drawer()
            {
                Console.CursorVisible = false;
            }
            public void DrawInitialNode
            (int initialNodeX, int initialNodeY, ConsoleColor initialNodeColor, char initialNodeSymbol)
            {
                Console.ForegroundColor = initialNodeColor;
                Console.SetCursorPosition(initialNodeX, initialNodeY);
                Console.Write(initialNodeSymbol);
            }

            public void DrawWinner(int shiftX, int shiftY, int width)
            {
                Console.SetCursorPosition(shiftX + width + 3, shiftY);
                Console.Write("winners:");
            }

            public void DrawLooser(int currentX, int currentY, ConsoleColor currentColor, char currentSymbol,
                int shiftX, int shiftY, int width)
            {
                Console.ForegroundColor = currentColor;
                Console.SetCursorPosition(currentX, currentY);
                Console.Write(currentSymbol);
                Console.SetCursorPosition(shiftX + width + 13, shiftY);
                Console.Write("looser:");
                Console.SetCursorPosition(shiftX + width + 13, shiftY + 1);
                Console.Write(currentSymbol);
                Console.ReadKey();
            }

            public void DrawNodeList(IEnumerable<ConsoleNode> nodes)
            {
                foreach (var consoleNode in nodes)
                {
                    DrawNode(consoleNode);
                }
            }

            public void DrawNode(ConsoleNode node)
            {
                Console.ForegroundColor = node.NodeColor;
                Console.SetCursorPosition(node.X, node.Y);
                Console.Write(node.NodeSymbol);
            }

            public void DrawGameField(GameField field, char symbol)
            {
                int frameX = field.X - 1;
                int frameY = field.Y - 1;
                int frameHeight = field.Height + 2;
                int frameWidth = field.Width + 2;

                for (int i = 0; i < frameHeight; i++)
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.SetCursorPosition(frameX, frameY + i);
                    for (int j = 0; j < frameWidth; j++)
                    {
                        if (i == 0 || i == frameHeight - 1)
                            Console.Write(symbol);
                        else if (j == 0 || j == frameWidth - 1)
                            Console.Write(symbol);
                        else Console.Write(" ");

                    }
                    Console.WriteLine("\n");
                }
            }




            public void DrawListAndMessage(List<ConsoleNode> nodes, GameField field, int shift, string message)
            {
                Console.SetCursorPosition(field.X + field.Width + 1 + shift, field.Y - 1);
                Console.Write(message);

                for (int nodeCounter = 0; nodeCounter < nodes.Count; nodeCounter++)
                {
                    Console.ForegroundColor = nodes[nodeCounter].NodeColor;
                    Console.SetCursorPosition(field.X + field.Width + 1 + shift, field.Y + nodeCounter);
                    Console.Write(nodes[nodeCounter].NodeSymbol);
                    Console.ForegroundColor = ConsoleColor.Gray;

                }
            }

        }
    }

